package com.ybxx.asset.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.ybxx.asset.dao.NightLifeDao;
import com.ybxx.asset.model.NightLife;
import com.ybxx.asset.model.Trench;
import com.ybxx.asset.service.NightLifeService;
import com.ybxx.core.command.QueryFilter;
import com.ybxx.core.dao.GenericDao;
import com.ybxx.core.service.impl.BaseServiceImpl;

public class NightLifeServiceImpl extends BaseServiceImpl<NightLife> implements
		NightLifeService {
	private NightLifeDao nightLifeDao;
	public NightLifeServiceImpl(NightLifeDao dao) {
		super(dao);
		this.nightLifeDao=dao;
		// TODO Auto-generated constructor stub
	}
	public List<NightLife> queryPage(NightLife nightLife, QueryFilter filter) {
		String hql="from NightLife n where 1=1 ";
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getTdzh())){
			hql+=" and n.tdzh like '%"+nightLife.getTdzh()+"%'";
		}
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getNlname())){
			hql+=" and n.nlname like '%"+nightLife.getNlname()+"%'";
		}
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getZdh())){
			hql+=" and n.zdh like '%"+nightLife.getZdh()+"%'";
		}
		
		return nightLifeDao.findByHql(hql, null, filter.getPagingBean());
	}
	public List<NightLife> exportExcel_Print(NightLife nightLife) {
		String hql="from NightLife n left join fetch n.company c where 1=1 ";
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getTdzh())){
			hql+=" and n.tdzh like '%"+nightLife.getTdzh()+"%'";
		}
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getNlname())){
			hql+=" and n.nlname like '%"+nightLife.getNlname()+"%'";
		}
		if(nightLife!=null && StringUtils.isNotEmpty(nightLife.getZdh())){
			hql+=" and n.zdh like '%"+nightLife.getZdh()+"%'";
		}
		
		return nightLifeDao.findByHql(hql, null);
	}
	@Override
	public NightLife get(String id) {
		String hql="from NightLife n left join fetch n.company c where nlid='"+id+"' ";
		return (NightLife)nightLifeDao.findUnique(hql, null);
	}
}
